/// 
/// Author: Jeff Liu
/// Date: 2023-04-10 13:37:37
/// LastEditTime: 2023-04-10 17:50:05
/// LastEditors: Jeff Liu
/// Description: 
/// FilePath: /HCC3T/src/HCC/Utils/TestData.cls
/// Jeff.liu@intersytems.com
/// 
Class HCC.Utils.TestData
{

ClassMethod Populate(DocID As %String, Name As %String, PID As %String) As %Status
{
    Set sc = $$$OK
   // Get a stream of XML from the XData block contained in this class
   Set xdataID="HCC.Utils.TestData||PopulatorScript"
   Set compiledXdata=##class(%Dictionary.CompiledXData).%OpenId(xdataID)
   Set tStream=compiledXdata.Data
   If '$ISOBJECT(tStream) Set tSC=%objlasterror Quit
   
   Set status=##class(%XML.TextReader).ParseStream(tStream,.textreader)
   //check status
   If $$$ISERR(status) Do $SYSTEM.Status.DisplayError(status) Quit
   
   //iterate through document, node by node
   While textreader.Read()
   {
       If (textreader.NodeType="chars")
       {
  Set value=textreader.Value
  Set tStatement = ##class(%SQL.Statement).%New()
  Set qStatus = tStatement.%Prepare(value)
  If qStatus'=1 {Write "%Prepare failed:" Do $SYSTEM.Status.DisplayError(qStatus) Quit}
  Set rset = tStatement.%Execute()
       }
   }
    Quit sc
}

XData PopulatorScript
{
<SQL>    insert into HCC_SQL.Document(
    DocumentNo,
    DocumentType)
    values(
    'Doc20220112',/*插入文档*/
    32);
   
    </SQL>
}

}
